package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 声学类型枚举
 */
@AllArgsConstructor
@Getter
public enum IsfdAcousticsTypeEnum {
    ACOUSTICS("ACOUSTICS", "声学"),
    MODEL("MODEL", "模型"),
    ISOTROPIC_SOLID("ISOTROPIC_SOLID", "固体材料"),
    POROUS("POROUS", "多孔材料"),
    FLUID("FLUID", "液体材料");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdAcousticsTypeEnum isfdAcousticsTypeEnum = forValue(value);
        if (isfdAcousticsTypeEnum == null) {
            return null;
        }
        return isfdAcousticsTypeEnum.getDesc();
    }

    public static IsfdAcousticsTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdAcousticsTypeEnum isfdAcousticsTypeEnum : IsfdAcousticsTypeEnum.values()) {
            if (isfdAcousticsTypeEnum.getValue().equals(value)) {
                return isfdAcousticsTypeEnum;
            }
        }
        return null;
    }

    public static IsfdAcousticsTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdAcousticsTypeEnum isfdAcousticsTypeEnum : IsfdAcousticsTypeEnum.values()) {
            if (desc.equals(isfdAcousticsTypeEnum.getDesc())) {
                return isfdAcousticsTypeEnum;
            }
        }
        return null;
    }
}
